#include "AlgorithmManager.hpp"
#include "BufferImage.hpp"
#include "Client_types.h"
#include <spdlog/spdlog.h>
#include <stdexcept>
#include <unistd.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb/stb_image.h>

int width, height, channel;
unsigned char *data;
Thrift::ImageFormat::type type;

int main() {
  data = stbi_load("/home/shenzhe/Code/ImageExample/d/0.png", &width, &height,
                   &channel, 0);
  if (!data)
    throw std::runtime_error("Can't open test image");
  switch (channel) {
  case 1:
    type = Thrift::ImageFormat::GERY;
    break;
  case 3:
    type = Thrift::ImageFormat::RGB8;
    break;
  }
  AlgorithmManager manager;
  manager.funcGetData = []() -> BufferImage {
    spdlog::info("Call funcGetData");
    return BufferImage{.width = width,
                       .height = height,
                       .frameID = 0,
                       .type = type,
                       .data = data};
  };
  manager.funcSendResult = [](std::string name, std::string value) {
    spdlog::info("Call funcSendResult");
    spdlog::info("Result: {} -> {}", name, value);
  };
  std::deque<ClientPara> list = {{"单目位姿估计", "192.168.1.5", 14005}};
  manager.Boot(list);
  while (sleep(10) == 0)
    ;
  return 0;
}
